package com.jintoufs.weixin;

import com.jintoufs.domain.banner.Banner;
import org.cosmos.modules.web.msg.AjaxMsg;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@Scope("prototype")
@RequestMapping("/banner")
public class BannerAction extends SupportAction {

    @Value("${appId}")
    private String appId;

    /**
     * 获取banner列表
     */
    @RequestMapping("/list")
    @ResponseBody
    public AjaxMsg getTaskList() {
        AjaxMsg ajaxMsg = new AjaxMsg();
        try {
            Banner banner = new Banner("http://www.sznews.com/photo/images/attachement/jpg/site3/20150316/4437e6297838167069b213.jpg", "banner1", "");
            Banner banner1 = new Banner("http://www.sznews.com/photo/images/attachement/jpg/site3/20150316/4437e6297838167069b214.jpg", "banner1", "");
            Banner banner2 = new Banner("http://www.sznews.com/photo/images/attachement/jpg/site3/20150316/4437e6297838167069b215.jpg", "banner1", "");
            List<Banner> banners = new ArrayList<>();
            banners.add(banner);
            banners.add(banner1);
            banners.add(banner2);
            ajaxMsg.setDatas(banners);
        } catch (Exception e) {
            ajaxMsg.setMessage("系统出错，获取列表失败！");
            ajaxMsg.setCode(AjaxMsg.FAILURE);
        }
        return ajaxMsg;
    }
}
